<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>B页面</title>
  <button type="button" onclick="sendA()">发送A页面消息</button>
</head>
<body>
  <h1>B页面</h1>
  <span></span>
  <script>
    window.name='B'
    function sendA(){
      let targetWindow=window.opener;
      console.log(targetWindow,'window.opener');
      targetWindow.postMessage('郝总','http://127.0.0.1:60182')
    }
  </script>
</body>
</html>